package com.lincoln.cloud.servercenter.protocol;

import com.lincoln.cloud.common.utils.CommondValue;
import com.lincoln.cloud.servercenter.bean.ServerCenterContext;
import com.lincoln.framework.annotation.Execute;
import com.lincoln.framework.bean.AbstractMsgNoExecute;
import com.lincoln.framework.interfaces.BaseProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 通过服务器名获取服务器信息{[no]|获取ip|1|[app-name]|[md5]}
 * @author admin
 */
@Execute(deviceType = 1, protocolType = 1)
public class AchieveAllServers extends AbstractMsgNoExecute {
    private static final Logger logger = LoggerFactory.getLogger(AchieveAllServers.class);

    @Override
    public byte[] getServerCmd() {
        return CommondValue.ALL_ACHIEVE_SERVER_CMD.getBytes();
    }


    @Override
    public byte[] getClientCmd() {
        return CommondValue.ALL_ACHIEVE_CLIENT_CMD.getBytes();
    }

    @Override
    public Logger getLogger() {
        return logger;
    }


    @Override
    public boolean decoder(BaseProtocol protocol) {
        return true;
    }

    @Override
    public boolean execute(BaseProtocol protocol) {
        try {
            return ServerCenterContext.communicationProtocol().achieveServers();
        } catch (Exception e) {
            return false;
        }
    }
}
